package com.atguigu.gmall.product.api;

import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.service.SkuManageService;
import com.atguigu.gmall.product.service.SpuManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/product")
public class ProductApiController {
    @Autowired
    private SkuManageService skuManageService;
    @Autowired
    private SpuManageService spuManageService;

    @GetMapping("/inner/getSkuInfo/{skuId}")
    public SkuInfo getSkuInfo(@PathVariable Long skuId){
        return skuManageService.getSkuInfo(skuId);
    }

    @GetMapping("/inner/getGategoryView/{category3Id}")
    public BaseCategoryView getGategoryView(@PathVariable Long category3Id){
        return skuManageService.getGategoryView(category3Id);
    }

    @GetMapping("/inner/getSkuPrice/{skuId}")
    public BigDecimal getSkuPrice(@PathVariable Long skuId){
      return   skuManageService.getSkuPrice(skuId);
    }
    //根据spuId获取海报信息
    @GetMapping("/inner/findSpuPosterBySpuId/{spuId}")
    public List<SpuPoster> findSpuPosterBySpuId(@PathVariable Long spuId){
      return   spuManageService.findSpuPosterBySpuId(spuId);
    }
    //根据skuId查询平台属性----规格与包装
    @GetMapping("/inner/getAttrList/{skuId}")
    public List<BaseAttrInfo> getAttrList(@PathVariable Long skuId){
        return skuManageService.getAttrList(skuId);
    }

    //根据spuId 和 skuId做销售属性的回显
    @GetMapping("/inner/getSpuSaleAttrListCheckBySku/{skuId}/{spuId}")
    public List<SpuSaleAttr> getSpuSaleAttrListCheckBySku(@PathVariable Long skuId,
                                                          @PathVariable Long spuId){
        return spuManageService.getSpuSaleAttrListCheckBySku(skuId,spuId);
    }
    //商品的切换功能实现
    @GetMapping("/inner/getSkuValueIdsMap/{spuId}")
    public Map getSkuValueIdsMap(@PathVariable Long spuId){
        return skuManageService.getSkuValueIdsMap(spuId);
    }
}
